package com.baizhi.service;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liukaixuan
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{

    @Resource
    private UserDao userDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public User queryById(Integer id) {
        User user = userDao.queryById(id);
        return user;
    }

    @Override
    public User insert(User user) {
        user.setName(user.getPhone());
        userDao.insert(user);
        return user;
    }

    @Override
    public User findByPhone(String phone) {

        List<User> userList = userDao.findAllUser_Info();

        return userDao.findByPhone(phone);
    }

    @Override
    public User update(User user) {
        return null;
    }
}
